package com.xuecheng.filesystem.controller;

import com.xuecheng.api.filesystem.FileSystemCoursePicControllerApi;
import com.xuecheng.filesystem.service.FileSystemService;
import com.xuecheng.framework.domain.filesystem.response.UploadFileResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 课程图片上传接口
 */
@RestController
@RequestMapping("/fileSystem/coursePic")
public class FileSystemCoursePicController implements FileSystemCoursePicControllerApi {

    @Resource
    FileSystemService fileSystemService;

    /**
     * 课程图片上传接口
     *
     * @param multipartFile 文件
     * @param businesskey   业务key
     * @param filetag       文件标签
     * @param metadata      元信息,Json字符,服务器会转换成Map对象
     * @return 上传后响应
     */
    @Override
    @PostMapping("/upload")
    public UploadFileResult upload(MultipartFile multipartFile,
                                   String businesskey, String filetag, String metadata) {
        return fileSystemService.upload(multipartFile,businesskey,filetag,metadata);
    }
}
